<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>ActionView::Helpers::OutputSafetyHelper</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <link rel="stylesheet" href="../../../css/reset.css" type="text/css" media="screen" />
<link rel="stylesheet" href="../../../css/main.css" type="text/css" media="screen" />
<link rel="stylesheet" href="../../../css/github.css" type="text/css" media="screen" />
<script src="../../../js/jquery-1.3.2.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../js/jquery-effect.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../js/main.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../js/highlight.pack.js" type="text/javascript" charset="utf-8"></script>

</head>

<body>     
    <div class="banner">
        
            <span>Ruby on Rails v4.0.0</span><br />
        
        <h1>
            <span class="type">Module</span> 
            ActionView::Helpers::OutputSafetyHelper 
            
        </h1>
        <ul class="files">
            
            <li><a href="../../../files/actionpack/lib/action_view/helpers/output_safety_helper_rb.html">actionpack/lib/action_view/helpers/output_safety_helper.rb</a></li>
            
        </ul>
    </div>
    <div id="bodyContent">
        <div id="content">
  


  


  
  


  


  
    <!-- Method ref -->
    <div class="sectiontitle">Methods</div>
    <dl class="methods">
      
        <dt>R</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="OutputSafetyHelper.html#method-i-raw">raw</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>S</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="OutputSafetyHelper.html#method-i-safe_join">safe_join</a>
              </li>
            
          </ul>
        </dd>
      
    </dl>
  

  



  

    

    

    


    


    <!-- Methods -->
        
      <div class="sectiontitle">Instance Public methods</div>
      
        <div class="method">
          <div class="title method-title" id="method-i-raw">
            
              <b>raw</b>(stringish)
            
            <a href="OutputSafetyHelper.html#method-i-raw" name="method-i-raw" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>This method outputs without escaping a string. Since escaping tags is now
default, this can be used when you don’t want <a
href="../../Rails.html">Rails</a> to automatically escape tags. This is not
recommended if the data is coming from the user’s input.</p>

<p>For example:</p>

<pre class="ruby"><span class="ruby-identifier">raw</span> <span class="ruby-ivar">@user</span>.<span class="ruby-identifier">name</span>
<span class="ruby-comment"># =&gt; 'Jimmy &lt;alert&gt;Tables&lt;/alert&gt;'</span>
</pre>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-raw_source')" id="l_method-i-raw_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/5ab0c5dc22682647090aa4b84739910e079913d8/actionpack/lib/action_view/helpers/output_safety_helper.rb#L16" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-raw_source" class="dyn-source">
                <pre><span class="ruby-comment"># File actionpack/lib/action_view/helpers/output_safety_helper.rb, line 16</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">raw</span>(<span class="ruby-identifier">stringish</span>)
  <span class="ruby-identifier">stringish</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">html_safe</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-safe_join">
            
              <b>safe_join</b>(array, sep=$,)
            
            <a href="OutputSafetyHelper.html#method-i-safe_join" name="method-i-safe_join" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>This method returns a html safe string similar to what
<code>Array#join</code> would return. All items in the array, including the
supplied separator, are html escaped unless they are html safe, and the
returned string is marked as html safe.</p>

<pre class="ruby"><span class="ruby-identifier">safe_join</span>([<span class="ruby-string">&quot;&lt;p&gt;foo&lt;/p&gt;&quot;</span>.<span class="ruby-identifier">html_safe</span>, <span class="ruby-string">&quot;&lt;p&gt;bar&lt;/p&gt;&quot;</span>], <span class="ruby-string">&quot;&lt;br /&gt;&quot;</span>)
<span class="ruby-comment"># =&gt; &quot;&lt;p&gt;foo&lt;/p&gt;&amp;lt;br /&amp;gt;&amp;lt;p&amp;gt;bar&amp;lt;/p&amp;gt;&quot;</span>

<span class="ruby-identifier">safe_join</span>([<span class="ruby-string">&quot;&lt;p&gt;foo&lt;/p&gt;&quot;</span>.<span class="ruby-identifier">html_safe</span>, <span class="ruby-string">&quot;&lt;p&gt;bar&lt;/p&gt;&quot;</span>.<span class="ruby-identifier">html_safe</span>], <span class="ruby-string">&quot;&lt;br /&gt;&quot;</span>.<span class="ruby-identifier">html_safe</span>)
<span class="ruby-comment"># =&gt; &quot;&lt;p&gt;foo&lt;/p&gt;&lt;br /&gt;&lt;p&gt;bar&lt;/p&gt;&quot;</span>
</pre>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-safe_join_source')" id="l_method-i-safe_join_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/5ab0c5dc22682647090aa4b84739910e079913d8/actionpack/lib/action_view/helpers/output_safety_helper.rb#L31" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-safe_join_source" class="dyn-source">
                <pre><span class="ruby-comment"># File actionpack/lib/action_view/helpers/output_safety_helper.rb, line 31</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">safe_join</span>(<span class="ruby-identifier">array</span>, <span class="ruby-identifier">sep</span>=<span class="ruby-identifier">$,</span>)
  <span class="ruby-identifier">sep</span> = <span class="ruby-constant">ERB</span><span class="ruby-operator">::</span><span class="ruby-constant">Util</span>.<span class="ruby-identifier">html_escape</span>(<span class="ruby-identifier">sep</span>)

  <span class="ruby-identifier">array</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span> <span class="ruby-constant">ERB</span><span class="ruby-operator">::</span><span class="ruby-constant">Util</span>.<span class="ruby-identifier">html_escape</span>(<span class="ruby-identifier">i</span>) }.<span class="ruby-identifier">join</span>(<span class="ruby-identifier">sep</span>).<span class="ruby-identifier">html_safe</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
                    </div>

    </div>
  </body>
</html>    